Skip to content

Conversation

@bendichter
Copy link
Contributor

related to #626

@bendichter bendichter requested a review from stephprince October 9, 2025 00:12
Copy link
Contributor

@stephprince stephprince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added my review, could you also add a CHANGELOG entry?

return None


@register_check(importance=Importance.CRITICAL, neurodata_type=TimeSeries)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be critical or a best practice violation?

Comment on lines 563 to 580
def test_check_rate_not_below_threshold_fail_period_like_value():
"""Test detection when period was likely used instead of rate."""
# If someone uses 2.0 thinking it's a 2 second period, the rate should be 0.5 Hz
period_value = 2.0
time_series = pynwb.TimeSeries(
name="test_time_series",
unit="test_units",
data=np.zeros(shape=100),
starting_time=0.0,
rate=period_value,
)
result = check_rate_not_below_threshold(time_series)
# Should pass with default threshold since 2.0 > 0.01
assert result is None

# But should fail with a custom threshold
result = check_rate_not_below_threshold(time_series, low_rate_threshold=5.0)
assert result is not None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_check_rate_not_below_threshold_fail_period_like_value():
"""Test detection when period was likely used instead of rate."""
# If someone uses 2.0 thinking it's a 2 second period, the rate should be 0.5 Hz
period_value = 2.0
time_series = pynwb.TimeSeries(
name="test_time_series",
unit="test_units",
data=np.zeros(shape=100),
starting_time=0.0,
rate=period_value,
)
result = check_rate_not_below_threshold(time_series)
# Should pass with default threshold since 2.0 > 0.01
assert result is None
# But should fail with a custom threshold
result = check_rate_not_below_threshold(time_series, low_rate_threshold=5.0)
assert result is not None

I think this test covers the same behavior as the test above and below?

Comment on lines 453 to 457
result = check_time_series_duration(time_series)
assert result is not None
assert "long_time_series" in result.message
assert "exceeds the threshold" in result.message
assert result.importance == Importance.BEST_PRACTICE_SUGGESTION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update these to be checked against the full inspector message? Similarly in the other tests.

e.g. check_time_series_duration(time_series) == InspectorMessage(...

Comment on lines 463 to 472
one_year = 31557600.0
rate = 1.0 # 1 Hz
num_samples = int(one_year + 1000) # More than 1 year worth of samples
time_series = pynwb.TimeSeries(
name="long_time_series",
unit="test_units",
data=np.zeros(shape=num_samples),
starting_time=0.0,
rate=rate,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to avoid creating a large array here just for tests, could lower the rate instead to minimize the number of samples

"""
Check if the TimeSeries duration is longer than the specified threshold.
The default threshold is 1 year (31,557,600 seconds = 365.25 days).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for the year long threshold? I imagine anything longer than a month or two could be worth flagging since it is a best practice suggestion.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.91%. Comparing base (8a777a1) to head (6cf9922).

Files with missing lines Patch % Lines
src/nwbinspector/checks/_time_series.py 93.10% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #627      +/-   ##
==========================================
+ Coverage   73.03%   76.91%   +3.88%     
==========================================
  Files          47       47              
  Lines        1587     1616      +29     
==========================================
+ Hits         1159     1243      +84     
+ Misses        428      373      -55     
Files with missing lines Coverage Δ
src/nwbinspector/checks/__init__.py 100.00% <ø> (ø)
src/nwbinspector/checks/_time_series.py 91.80% <93.10%> (+0.40%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants